﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using MarginTrading.Entity;
using MarginTrading.Common;
using System.Data.OracleClient;
using System.Data;


namespace MarginTrading.Services
{
    public class LogService
    {
        public static void Add(int code, string user, string msg)
        {
            OracleConnection con = new OracleConnection();

            try
            {
                con.ConnectionString = Constants.DB_CONNECTION_STRING;
                con.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.CommandText = "INSERT INTO ACTION_LOG(LOG_TIME, LOG_CODE, LOG_MSG, LOG_USER) VALUES(:v1, :v2, :v3, :v4)";
                cmd.Parameters.Add(":v1", OracleType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add(":v2", OracleType.Int16).Value = code;
                cmd.Parameters.Add(":v3", OracleType.VarChar).Value = msg;
                cmd.Parameters.Add(":v4", OracleType.VarChar).Value = user;

                cmd.Connection = con;
                cmd.ExecuteNonQuery();

            }
            catch (System.Exception exc)
            {
                //throw;
            }
            finally
            {
                con.Close();
            }
        }
    }
}
